package com.example.guitinnhan;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView.BufferType;

public class GuiTinNhanActivity extends Activity implements OnClickListener{

	private Button btnDel,btnVietTN;
	private EditText edtNum;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_gui_tin_nhan);
		ThamChieu();
	}
	private void ThamChieu()
	{
		//btnDel = (Button)findViewById(R.id.btnDel);
		btnVietTN = (Button)findViewById(R.id.btnVietTN);
		edtNum = (EditText)findViewById(R.id.edtNum);
	}
	 /*void delText()
	 {
         CharSequence start = edtNum.getText();
         String ret = start.toString();
         int len = ret.length();
         if(len>0){
                 ret = ret.substring(0, len-1);
         }
         //ret.f
         edtNum.setText(ret,BufferType.EDITABLE);
         //dialNumber
         edtNum.setInputType(InputType.TYPE_CLASS_PHONE);
	 }*/
	public void VietTinNhan(View v) {
		// TODO Auto-generated method stub
		String sdt = edtNum.getText().toString();
		Intent i = new Intent(Intent.ACTION_SENDTO);
		i.setData( Uri.parse("sms:"+sdt));
		i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		//i.putExtra("sms_body", "Noi dung");
		startActivity(i);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		//if(v.getId() == btnDel.getId()){ delText(); }
		
		if (v.getId() == btnVietTN.getId()){VietTinNhan(btnVietTN);}
		
	}
}
